USE [db_9b1192_JerryEnglish2]
GO

/****** Object:  StoredProcedure [dbo].[spAddAchievement]    Script Date: 12/16/2014 00:36:44 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[spAddAchievement] 
	-- Add the parameters for the stored procedure here
	(	
		@Name				nvarchar(256),
		@Description		nvarchar(256),
		@Criteria			nvarchar(max),
		@ResourceUrl		nvarchar(max),
		@ActionName			nvarchar(256)			
	)
AS
Declare @ActionType BIGINT;
set @ActionType = 0;
select @ActionType = Id from ActionType where @ActionName = Name;
if(@ActionType > 0)
BEGIN
		--SET NOCOUNT ON;	 
		insert into Achievement (Name, Description, ActionType, Criteria, ResourceUrl, CreatedOn, LastModifiedDate, LastModifiedBy) 
		values (@Name, @Description, @ActionType, @Criteria, @ResourceUrl, GETDATE(), GETDATE(), 'System')
END


GO

